package com.coffee.takeoutserver;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

/**
 * 这个配置类的作用：能够直接方位image下的文件了
 */
@Configuration
public class MyPicConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        File rootDir = new File("src/main/resources/static/image");
        System.out.println(rootDir.getAbsolutePath());
        registry.addResourceHandler("/image/**").addResourceLocations("file:"+rootDir.getAbsolutePath()+File.separator);
    }
}
